(* Content-type: application/mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 7.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       145,          7]
NotebookDataLength[     11132,        306]
NotebookOptionsPosition[     10493,        283]
NotebookOutlinePosition[     10831,        298]
CellTagsIndexPosition[     10788,        295]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{
Cell[BoxData[{
 RowBox[{"dataFilename", "=", 
  RowBox[{
  "SystemDialogInput", "[", "\"\<FileOpen\>\"", 
   "]"}]}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"bgFilename", "=", 
   RowBox[{"StringReplace", "[", 
    RowBox[{"dataFilename", ",", 
     RowBox[{"\"\<data.txt\>\"", "\[Rule]", " ", "\"\<bg.jpg\>\""}]}], 
    "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"dirName", "=", 
   RowBox[{"DirectoryName", "[", "dataFilename", "]"}]}], 
  ";"}], "\[IndentingNewLine]"}], "Input",
 CellChangeTimes->{{3.4800041004748898`*^9, 3.48000410342467*^9}, {
  3.480970698947402*^9, 3.480970700526463*^9}, {3.480970822940189*^9, 
  3.480970840792304*^9}}],

Cell[BoxData[{
 RowBox[{
  RowBox[{"data", "=", 
   RowBox[{"Import", "[", 
    RowBox[{"dataFilename", ",", "\"\<Data\>\""}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"bg", "=", 
   RowBox[{"ColorConvert", "[", " ", 
    RowBox[{
     RowBox[{"Import", "[", "bgFilename", "]"}], ",", "\"\<Grayscale\>\""}], 
    "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"pos", " ", "=", " ", 
    RowBox[{"data", "[", 
     RowBox[{"[", 
      RowBox[{"All", ",", 
       RowBox[{"{", 
        RowBox[{"2", ",", "3"}], "}"}]}], "]"}], "]"}]}], ";"}], " ", 
  RowBox[{"(*", " ", 
   RowBox[{
   "2", "nd", " ", "and", " ", "third", " ", "columns", " ", "are", " ", 
    "the", " ", "position"}], "*)"}]}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"time", "=", " ", 
   RowBox[{"data", "[", 
    RowBox[{"[", 
     RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ";"}]}], "Input",
 CellChangeTimes->{{3.4786339971678963`*^9, 3.478634004809433*^9}, {
  3.478634047403926*^9, 3.478634091682213*^9}, {3.479999579899847*^9, 
  3.479999581475164*^9}, {3.479999645215384*^9, 3.4799996455516787`*^9}, {
  3.480004324870799*^9, 3.480004325109254*^9}, {3.480802452800097*^9, 
  3.480802469893368*^9}, {3.480805214354912*^9, 3.480805231761768*^9}, {
  3.480805308870775*^9, 3.480805327206337*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"(*", 
   RowBox[{
   "funciton", " ", "to", " ", "plot", " ", "path", " ", "in", " ", "color"}],
    "*)"}], 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{"pathPlot", "[", "pos_", "]"}], ":=", 
    RowBox[{"With", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"pos3d", "=", 
         RowBox[{"Transpose", "[", 
          RowBox[{
           RowBox[{"Transpose", "[", "pos", "]"}], "~", "Join", "~", 
           RowBox[{"{", 
            RowBox[{"Rescale", "[", "time", "]"}], "}"}]}], "]"}]}], ",", 
        RowBox[{"linesFrom", "=", 
         RowBox[{"pos3d", "[", 
          RowBox[{"[", 
           RowBox[{"1", ";;", 
            RowBox[{"-", "2"}]}], "]"}], "]"}]}], ",", 
        RowBox[{"linesTo", "=", 
         RowBox[{"pos3d", "[", 
          RowBox[{"[", 
           RowBox[{"2", ";;"}], "]"}], "]"}]}], ",", 
        RowBox[{"lines", "=", 
         RowBox[{"Transpose", "[", 
          RowBox[{
           RowBox[{"{", "linesFrom", "}"}], "~", "Join", "~", 
           RowBox[{"{", "linesTo", "}"}]}], "]"}]}]}], "}"}], ",", 
      RowBox[{"{", 
       RowBox[{"pos3d", ",", 
        RowBox[{"Graphics", "[", 
         RowBox[{"Map", "[", 
          RowBox[{
           RowBox[{
            RowBox[{"{", 
             RowBox[{
              RowBox[{"Thickness", "[", "0.005", "]"}], ",", 
              RowBox[{"Opacity", "[", "0.5", "]"}], ",", 
              RowBox[{"Hue", "[", 
               FractionBox[
                RowBox[{"#", "[", 
                 RowBox[{"[", 
                  RowBox[{"1", ",", "3"}], "]"}], "]"}], "1.5"], "]"}], ",", 
              RowBox[{"Line", "[", 
               RowBox[{"#", "[", 
                RowBox[{"[", 
                 RowBox[{"All", ",", 
                  RowBox[{"{", 
                   RowBox[{"1", ",", "2"}], "}"}]}], "]"}], "]"}], "]"}]}], 
             "}"}], "&"}], ",", "lines"}], "]"}], "]"}]}], "}"}]}], "]"}]}], 
   "*)"}]}]], "Input",
 CellChangeTimes->{{3.480803640160237*^9, 3.480803647494199*^9}, {
  3.480803686625585*^9, 3.480803694237361*^9}, {3.480803821624134*^9, 
  3.480803823091309*^9}, {3.480804282958404*^9, 3.480804433834803*^9}, {
  3.480804470403233*^9, 3.480804473695427*^9}, {3.480804646271328*^9, 
  3.480804655086951*^9}, {3.480804814612055*^9, 3.480804984844449*^9}, {
  3.480805033310778*^9, 3.480805040760851*^9}, {3.480805082433085*^9, 
  3.480805130212355*^9}, {3.480805520350757*^9, 3.480805524868245*^9}, {
  3.480805597614318*^9, 3.480805598162172*^9}, {3.480805643356168*^9, 
  3.480805719522236*^9}, {3.480969993860759*^9, 3.480970024774303*^9}, {
  3.480970375985837*^9, 3.480970380467826*^9}}],

Cell[BoxData[{
 RowBox[{
  RowBox[{"pos3d", "=", 
   RowBox[{"Transpose", "[", 
    RowBox[{
     RowBox[{"Transpose", "[", "pos", "]"}], "~", "Join", "~", 
     RowBox[{"{", 
      RowBox[{"Rescale", "[", "time", "]"}], "}"}]}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"linesFrom", "=", 
   RowBox[{"pos3d", "[", 
    RowBox[{"[", 
     RowBox[{"1", ";;", 
      RowBox[{"-", "2"}]}], "]"}], "]"}]}], ";", 
  RowBox[{"linesTo", "=", 
   RowBox[{"pos3d", "[", 
    RowBox[{"[", 
     RowBox[{"2", ";;"}], "]"}], "]"}]}], ";", 
  RowBox[{"lines", "=", 
   RowBox[{"Transpose", "[", 
    RowBox[{
     RowBox[{"{", "linesFrom", "}"}], "~", "Join", "~", 
     RowBox[{"{", "linesTo", "}"}]}], "]"}]}], ";", 
  RowBox[{"pathG", "=", 
   RowBox[{"Graphics", "[", 
    RowBox[{"Map", "[", 
     RowBox[{
      RowBox[{
       RowBox[{"{", 
        RowBox[{
         RowBox[{"Thickness", "[", "0.005", "]"}], ",", 
         RowBox[{"Opacity", "[", "0.5", "]"}], ",", 
         RowBox[{"Hue", "[", 
          FractionBox[
           RowBox[{"#", "[", 
            RowBox[{"[", 
             RowBox[{"1", ",", "3"}], "]"}], "]"}], "1.5"], "]"}], ",", 
         RowBox[{"Line", "[", 
          RowBox[{"#", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", 
             RowBox[{"{", 
              RowBox[{"1", ",", "2"}], "}"}]}], "]"}], "]"}], "]"}]}], "}"}], 
       "&"}], ",", "lines"}], "]"}], "]"}]}], ";"}]}], "Input",
 CellChangeTimes->{{3.480970163694875*^9, 3.480970200309627*^9}, {
  3.480970231254186*^9, 3.480970232086852*^9}, {3.480970340451616*^9, 
  3.480970346380753*^9}}],

Cell[BoxData[
 RowBox[{"Show", "[", 
  RowBox[{
   RowBox[{"Graphics", "[", 
    RowBox[{"Raster", "[", 
     RowBox[{"ImageData", "[", 
      RowBox[{"ImageReflect", "[", "bg", "]"}], "]"}], "]"}], "]"}], ",", 
   "pathG"}], "]"}]], "Input",
 CellChangeTimes->{{3.478634150380966*^9, 3.478634154557136*^9}, {
  3.47863528797878*^9, 3.478635328873233*^9}, {3.47864683960574*^9, 
  3.478646872681666*^9}, {3.4786472107207336`*^9, 3.478647218277063*^9}, {
  3.478696281466858*^9, 3.478696310037468*^9}, {3.478696449117234*^9, 
  3.4786964519731417`*^9}, {3.4787211793369207`*^9, 3.478721192356347*^9}, {
  3.478721568963957*^9, 3.47872157837858*^9}, {3.478721667852696*^9, 
  3.4787216719119177`*^9}, {3.480805169614946*^9, 3.48080517638499*^9}, {
  3.480970352145301*^9, 3.480970354400317*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"speed", " ", "=", 
   RowBox[{"Map", "[", 
    RowBox[{"Norm", ",", 
     RowBox[{"Differences", "[", "pos", "]"}]}], "]"}]}], ";"}]], "Input",
 CellChangeTimes->{{3.478645919480521*^9, 3.478645921044614*^9}, {
  3.478646024808279*^9, 3.4786460454058533`*^9}, {3.478646129767611*^9, 
  3.4786461320299883`*^9}, {3.478646270143855*^9, 3.478646279990822*^9}, {
  3.478647225622604*^9, 3.478647226133485*^9}, {3.479999711938477*^9, 
  3.479999713899585*^9}, {3.480003909043291*^9, 3.4800039097361107`*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"speed95", "=", 
   RowBox[{
    RowBox[{"Sort", "[", "speed", "]"}], "[", 
    RowBox[{"[", 
     RowBox[{"1", ";;", 
      RowBox[{"Round", "[", 
       RowBox[{"0.95", "*", 
        RowBox[{"Length", "[", "speed", "]"}]}], "]"}]}], " ", "]"}], "]"}]}],
   ";"}]], "Input",
 CellChangeTimes->{{3.4811034482387*^9, 3.481103550717644*^9}}],

Cell[BoxData[
 RowBox[{"Histogram", "[", 
  RowBox[{"speed95", ",", 
   RowBox[{"PlotRange", "\[Rule]", "All"}]}], "]"}]], "Input",
 CellChangeTimes->{{3.480003862053508*^9, 3.4800038740608892`*^9}, {
  3.480003919225016*^9, 3.480003921040866*^9}, {3.481103203037533*^9, 
  3.481103206379452*^9}, {3.481103242079862*^9, 3.48110333319931*^9}, {
  3.481103558028274*^9, 3.481103558436009*^9}}],

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{"dataXYZ", "=", 
    RowBox[{"Transpose", "[", 
     RowBox[{"Append", "[", 
      RowBox[{
       RowBox[{"Transpose", "[", 
        RowBox[{"pos", "[", 
         RowBox[{"[", 
          RowBox[{"1", ";;", 
           RowBox[{"-", "2"}]}], "]"}], "]"}], " ", "]"}], ",", 
       RowBox[{"speed", "/", 
        RowBox[{"Max", "[", "speed", "]"}]}]}], "]"}], "]"}]}], " ", ";", 
   "\[IndentingNewLine]", 
   RowBox[{"ListPlot3D", "[", 
    RowBox[{"dataXYZ", ",", 
     RowBox[{"ColorFunction", "\[Rule]", 
      RowBox[{"Function", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{"x", ",", "y", ",", "z"}], "}"}], ",", 
        RowBox[{"Hue", "[", "z", "]"}]}], "]"}]}]}], "]"}]}], "*)"}]], "Input",\

 CellChangeTimes->{{3.4786475942842627`*^9, 3.47864767584192*^9}, {
  3.4786477679189663`*^9, 3.478647768006424*^9}, {3.478647898680996*^9, 
  3.478647904821751*^9}, {3.4786479778422937`*^9, 3.4786479844606028`*^9}, {
  3.478648046808982*^9, 3.4786480820807858`*^9}, {3.478649110088049*^9, 
  3.478649114542775*^9}, {3.479999750475643*^9, 3.4799997533401327`*^9}, {
  3.480003931147233*^9, 3.480003936293747*^9}, {3.48000427032419*^9, 
  3.480004279563861*^9}}],

Cell[BoxData[
 RowBox[{"totalDistanceTraveled", " ", "=", " ", 
  RowBox[{"Total", "[", "speed", "]"}]}]], "Input",
 CellChangeTimes->{{3.4786463422953663`*^9, 3.47864635025992*^9}, {
  3.4800039490671186`*^9, 3.480003956498872*^9}}],

Cell[BoxData[""], "Input",
 CellChangeTimes->{3.480804694854169*^9, 3.480804811504146*^9}]
},
WindowSize->{884, 724},
WindowMargins->{{193, Automatic}, {Automatic, 25}},
FrontEndVersion->"7.0 for Linux x86 (32-bit) (November 10, 2008)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[545, 20, 669, 17, 99, "Input"],
Cell[1217, 39, 1320, 34, 99, "Input"],
Cell[2540, 75, 2661, 65, 146, "Input"],
Cell[5204, 142, 1617, 47, 140, "Input"],
Cell[6824, 191, 793, 15, 32, "Input"],
Cell[7620, 208, 538, 10, 32, "Input"],
Cell[8161, 220, 373, 11, 32, "Input"],
Cell[8537, 233, 391, 7, 32, "Input"],
Cell[8931, 242, 1229, 30, 55, "Input"],
Cell[10163, 274, 233, 4, 32, "Input"],
Cell[10399, 280, 90, 1, 32, "Input"]
}
]
*)

(* End of internal cache information *)
